CC=gcc
CXX=g++
CFLAGS=-Wall $(DEBUG) $(DEFINITIONS) $(CINCLUDES) $(CMISCFLAGS)
CPPFLAGS=-Wall -ansi $(DEBUG) $(EXCEPTIONS) $(CPPINCLUDES) $(DEFINITIONS) $(CPPMISCFLAGS)
DEBUG=-O3 -g3
CMISCFLAGS=
CPPMISCFLAGS=-DGIMI_CLIENT_API=10303
DEFINITIONS=-DLINUX_OS -DGIMI_NO_DATATYPE_INCLUDES
EXCEPTIONS=-fexceptions -ffast-math 
CINCLUDES=-I. -I../../scanmatch -I../../mcl -I$(GDIR)utils
CPPINCLUDES=-I. -I../../scanmatch -I../../mcl $(OCCU_INCLUDE) -I$(GDIR)glutImageGUI -I$(GDIR)utils \
						-I$(GIMDIR)/JPEGEncoder

LD=g++
LDFLAGS=
LIBS=-lrt -lpthread -lGL -lGLU -lglut -ljpeg

GDIR=../../../../
GIMDIR=../../../..
SRCSC=
#SRCSCPP=j2b2.cpp $(OCCU_SRC_CPP)
VPATH=
CPPGIMI=
CGIMI=

include Makefile.mcl
LNMDIR=$(GDIR)/LnMlib/src

include $(LNMDIR)/map/Makefile.occu 

CSRCUTIL = $(GIMDIR)/utils/ownutils.c $(GIMDIR)/utils/owndebug.c
CPPIMAGEGUI = $(GIMDIR)/glutImageGUI/glutImageGUI.cpp  $(GIMDIR)/JPEGEncoder/JPEGEncoder.cpp

SRCSC += $(CSRCUTIL)
SRCSCPP=$(CPPIMAGEGUI) $(OCCU_SRC_CPP) $(CPPMCL) $(CPPSM)


## Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)

## Define compiles and links
COMPILEC=$(CC) $(CFLAGS) $(CINCLUDES) -c
COMPILECPP=$(CXX) $(CPPFLAGS) $(CPPINCLUDES) -c
LINK=$(LD) $(LDFLAGS) $(LIBS)

.PHONY: all clean

TARGETS=topo topo3D topo_vti

all: $(TARGETS)

						
topo: $(OBJSC) $(OBJSCPP) topo.opp
			@$(LINK) -o $@ $^ $(LIBS)
			@echo "      [LD] $@"
							
topo3D: $(OBJSC) $(OBJSCPP) topo3D.opp
			@$(LINK) -o $@ $^ $(LIBS)
			@echo "      [LD] $@"
topo_vti: $(OBJSC) $(OBJSCPP) topo_vti.opp
			@$(LINK) -o $@ $^ $(LIBS)
			@echo "      [LD] $@"
clean:
	rm -f $(OBJSC) $(OBJSCPP) *.opp *.o $(TARGETS) \
 		*.out *~ *.d *.dpp

## Compile rule for all .o (.c) file
%.o:    %.c
				$(COMPILEC) -o $@ $<

## Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
				$(COMPILECPP) -o $@ $<